package blog

import (
	"github.com/astaxie/beego"
)

type LoginController struct {
	beego.Controller
}

type User struct {
	username string
	password string
}

// @router /login [get]
func (this *LoginController) Get() {
	this.TplNames = "login.html"
}

// @router /login [post]
func (this *LoginController) Post() {
	name := this.GetString("name")
	pwd := this.GetString("pwd")
	inputuser := User{username: name, password: pwd}
	var user User
	user.password = beego.AppConfig.String("password")
	user.username = beego.AppConfig.String("username")
	if user != inputuser {
		this.Redirect("/login", 302)
	}
	this.SetSession("user", user)
	this.Redirect("/", 302)
}
